import { BaseEntity } from '@libs/common/entities';
import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, Index, JoinColumn } from 'typeorm';

import { AttendanceStatistic } from '@/hr/attendance-statistics/entities/attendance-statistic.entity';

@Index('workDate_dingId', ['workDate', 'dingId'], { unique: true })
@Entity('crm_node_hr_overtime_log')
export class OvertimeLog extends BaseEntity {
  @ApiProperty({ description: '钉钉 id' })
  @Column({ comment: '钉钉 id' })
  dingId: string;

  @ApiProperty({ description: '用户名' })
  @Column({ comment: '用户名' })
  userName: string;

  @ApiProperty({ description: '时长/单位分钟' })
  @Column({ comment: '时长', default: 0 })
  time: number;

  @ApiProperty({ description: '考勤时间' })
  @Column({ type: 'datetime', comment: '考勤时间' })
  workDate: Date | string;

  @JoinColumn({ name: 'attendanceStatistics' })
  attendanceStatistics: AttendanceStatistic;

  @Column({ comment: '考勤记录 ID', unique: true })
  attendanceStatisticsId: string;
}
